//
//  TSViewController.m
//  TSWebKit
//
//  Created by Reachstar on 10/27/2020.
//  Copyright (c) 2020 Reachstar. All rights reserved.
//

#import "TSViewController.h"
#import "TSWebView.h"
#import "TSBridgeManager.h"
#import "TSWebViewController.h"

@interface TSViewController ()

@end

@implementation TSViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton *btn = [[UIButton alloc] init];
    btn.frame =CGRectMake(100, 100, 100, 50);
    [btn setTitle:@"123123" forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    
    self.view.backgroundColor = [UIColor redColor];
//    CGRect bounds=self.view.bounds;
//    TSWebView * dwebview=[[TSWebView alloc] initWithFrame:CGRectMake(0, 25, bounds.size.width, bounds.size.height-25)];
//    [self.view addSubview:dwebview];
//    
//    [dwebview addJavascriptObject:[[TSBridgeManager alloc] initWithHandle:self] namespace:nil];
//
//    dwebview.navigationDelegate = self;
//
//    NSString *path = [[NSBundle mainBundle] bundlePath];
//    NSURL *baseURL = [NSURL fileURLWithPath:path];
//    NSString * htmlPath = [[NSBundle mainBundle] pathForResource:@"test"
//                                                          ofType:@"html"];
//    NSString * htmlContent = [NSString stringWithContentsOfFile:htmlPath
//                                                    encoding:NSUTF8StringEncoding
//                                                       error:nil];
//    [dwebview loadHTMLString:htmlContent baseURL:baseURL];


	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)click
{
    NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"drivingLicense" ofType:@"html"];
    TSWebViewController *vc = [[TSWebViewController alloc] initWithURL:@"http://127.0.0.1:5500/popularize/ubi/drivingScore.html"];
    [self.navigationController pushViewController:vc animated:YES];
}
@end
